Dynomotion

Group: DynoMotion Message: 7294 From: tapiolarikka Date: 4/19/2013
Subject: Understanding WatchEnable
Hi All!

I wanted to confirm if I have figured this correctly:

I want KFlop to monitor OptoIn7 and keep OptoOut1&2 the opposite of OptoIn7 at all times.

I understood that I could do this following WatchEnable example with

#include "KMotionDef.h"


main()
{
for (;;) //loop forever
{
WaitNextTimeSlice();

SetBit(xxx)=!Readbit(xxx) // OptoOut1<>OptoIn7;
SetBit(xxx)=!Readbit(xxx) // OptoOut2<>OptoIn7;
}
}


And launching this in separate thread

If the above is wrong please point out my error

Rgds,
Tapio
Group: DynoMotion Message: 7295 From: Tom Kerekes Date: 4/19/2013
Subject: Re: Understanding WatchEnable
Hi Tapio,

Wrong syntax and SetBit only sets bit.   To set a bit to a specified state call SetStateBit.

Try:

#include "KMotionDef.h"

#define OPTOIN7 143
#define OPTOOUT1 145
#define OPTOOUT2 146

main()
{
    for (;;) //loop forever
    {
        WaitNextTimeSlice();

        SetStateBit(OPTOOUT1, !ReadBit(OPTOIN7));
        SetStateBit(OPTOOUT2, !ReadBit(OPTOIN7));
    }
}


Group: DynoMotion Message: 7302 From: tapiolarikka Date: 4/20/2013
Subject: Re: Understanding WatchEnable
Hi!

Do I config the below watchenable code to run as separate thread?

I want it to run as soon as Kflop boots up, regardless if mach3 front-end is present or not.

the optoin monitors system control voltage and opto-outs control drive enable/run-inhibit that has control of the servomotor breaks.

Rgds
Tapio



--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi Tapio,
>
> Wrong syntax and SetBit only sets bit.   To set a bit to a specified state call SetStateBit.
>
> Try:
>
> #include "KMotionDef.h"
>
> #define OPTOIN7 143
> #define OPTOOUT1 145
> #define OPTOOUT2 146
>
> main()
> {
>     for (;;) //loop forever
>     {
>         WaitNextTimeSlice();
>
>         SetStateBit(OPTOOUT1, !ReadBit(OPTOIN7));
>         SetStateBit(OPTOOUT2, !ReadBit(OPTOIN7));
>     }
> }
>
>
>
>
> ________________________________
> From: tapiolarikka <tapio.larikka@...>
> To: DynoMotion@yahoogroups.com
> Sent: Friday, April 19, 2013 10:03 AM
> Subject: [DynoMotion] Understanding WatchEnable
>
>
>
>  
> Hi All!
>
> I wanted to confirm if I have figured this correctly:
>
> I want KFlop to monitor OptoIn7 and keep OptoOut1&2 the opposite of OptoIn7 at all times.
>
> I understood that I could do this following WatchEnable example with
>
> #include "KMotionDef.h"
>
> main()
> {
> for (;;) //loop forever
> {
> WaitNextTimeSlice();
>
> SetBit(xxx)=!Readbit(xxx) // OptoOut1<>OptoIn7;
> SetBit(xxx)=!Readbit(xxx) // OptoOut2<>OptoIn7;
> }
> }
>
> And launching this in separate thread
>
> If the above is wrong please point out my error
>
> Rgds,
> Tapio
>
Group: DynoMotion Message: 7303 From: TK Date: 4/20/2013
Subject: Re: Understanding WatchEnable
Hi Tapio,

You can download it to an unused Thread, set the thread to Launch on startup, then FLASH User Data.  But it isn't recommended. It seems like something better handled in hardware. KFLOP takes a few seconds to boot up. FLASHing User Data can be confusing. You will need to keep track of if/what is flashed in each board in case you ever want to upgrade versions or replace a board. It is easier if everything is always just initialized from scratch by the PC (Mach3).

Regards. 
TK

On Apr 20, 2013, at 5:20 AM, "tapiolarikka" <tapio.larikka@...> wrote:

 


Hi!

Do I config the below watchenable code to run as separate thread?

I want it to run as soon as Kflop boots up, regardless if mach3 front-end is present or not.

the optoin monitors system control voltage and opto-outs control drive enable/run-inhibit that has control of the servomotor breaks.

Rgds
Tapio

--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi Tapio,
>
> Wrong syntax and SetBit only sets bit.   To set a bit to a specified state call SetStateBit.
>
> Try:
>
> #include "KMotionDef.h"
>
> #define OPTOIN7 143
> #define OPTOOUT1 145
> #define OPTOOUT2 146
>
> main()
> {
>     for (;;) //loop forever
>     {
>         WaitNextTimeSlice();
>
>         SetStateBit(OPTOOUT1, !ReadBit(OPTOIN7));
>         SetStateBit(OPTOOUT2, !ReadBit(OPTOIN7));
>     }
> }
>
>
>
>
> ________________________________
> From: tapiolarikka <tapio.larikka@...>
> To: DynoMotion@yahoogroups.com
> Sent: Friday, April 19, 2013 10:03 AM
> Subject: [DynoMotion] Understanding WatchEnable
>
>
>
>  
> Hi All!
>
> I wanted to confirm if I have figured this correctly:
>
> I want KFlop to monitor OptoIn7 and keep OptoOut1&2 the opposite of OptoIn7 at all times.
>
> I understood that I could do this following WatchEnable example with
>
> #include "KMotionDef.h"
>
> main()
> {
> for (;;) //loop forever
> {
> WaitNextTimeSlice();
>
> SetBit(xxx)=!Readbit(xxx) // OptoOut1<>OptoIn7;
> SetBit(xxx)=!Readbit(xxx) // OptoOut2<>OptoIn7;
> }
> }
>
> And launching this in separate thread
>
> If the above is wrong please point out my error
>
> Rgds,
> Tapio
>

Group: DynoMotion Message: 7304 From: tapiolarikka Date: 4/20/2013
Subject: Re: Understanding WatchEnable
So the recommended way is to have 1 init.c and things that should loop forever should be place at the end of this file?.

I suppose KFlop runs with the loaded init it has until new init is loaded?

Meaning that I have Mach plugin set so that Kflop is initialized on every reset. If I hit limit or something else triggeres mach reset/e-stop then KFlop runs the time from hitting the limit to pressing reset with the init loaded at previous reset.


Rgds,
Tapio


--- In DynoMotion@yahoogroups.com, TK <tk@...> wrote:
>
> Hi Tapio,
>
> You can download it to an unused Thread, set the thread to Launch on startup, then FLASH User Data. But it isn't recommended. It seems like something better handled in hardware. KFLOP takes a few seconds to boot up. FLASHing User Data can be confusing. You will need to keep track of if/what is flashed in each board in case you ever want to upgrade versions or replace a board. It is easier if everything is always just initialized from scratch by the PC (Mach3).
>
> Regards.
> TK
>
> On Apr 20, 2013, at 5:20 AM, "tapiolarikka" <tapio.larikka@...> wrote:
>
> >
> > Hi!
> >
> > Do I config the below watchenable code to run as separate thread?
> >
> > I want it to run as soon as Kflop boots up, regardless if mach3 front-end is present or not.
> >
> > the optoin monitors system control voltage and opto-outs control drive enable/run-inhibit that has control of the servomotor breaks.
> >
> > Rgds
> > Tapio
> >
> > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > >
> > > Hi Tapio,
> > >
> > > Wrong syntax and SetBit only sets bit. To set a bit to a specified state call SetStateBit.
> > >
> > > Try:
> > >
> > > #include "KMotionDef.h"
> > >
> > > #define OPTOIN7 143
> > > #define OPTOOUT1 145
> > > #define OPTOOUT2 146
> > >
> > > main()
> > > {
> > > for (;;) //loop forever
> > > {
> > > WaitNextTimeSlice();
> > >
> > > SetStateBit(OPTOOUT1, !ReadBit(OPTOIN7));
> > > SetStateBit(OPTOOUT2, !ReadBit(OPTOIN7));
> > > }
> > > }
> > >
> > >
> > >
> > >
> > > ________________________________
> > > From: tapiolarikka <tapio.larikka@>
> > > To: DynoMotion@yahoogroups.com
> > > Sent: Friday, April 19, 2013 10:03 AM
> > > Subject: [DynoMotion] Understanding WatchEnable
> > >
> > >
> > >
> > >
> > > Hi All!
> > >
> > > I wanted to confirm if I have figured this correctly:
> > >
> > > I want KFlop to monitor OptoIn7 and keep OptoOut1&2 the opposite of OptoIn7 at all times.
> > >
> > > I understood that I could do this following WatchEnable example with
> > >
> > > #include "KMotionDef.h"
> > >
> > > main()
> > > {
> > > for (;;) //loop forever
> > > {
> > > WaitNextTimeSlice();
> > >
> > > SetBit(xxx)=!Readbit(xxx) // OptoOut1<>OptoIn7;
> > > SetBit(xxx)=!Readbit(xxx) // OptoOut2<>OptoIn7;
> > > }
> > > }
> > >
> > > And launching this in separate thread
> > >
> > > If the above is wrong please point out my error
> > >
> > > Rgds,
> > > Tapio
> > >
> >
> >
>
Group: DynoMotion Message: 7310 From: Tom Kerekes Date: 4/21/2013
Subject: Re: Understanding WatchEnable
Hi Tapio,

That is correct (if I understand your description).

Regards
TK